package com.zbkj.admin.controller.platform;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.zbkj.common.request.OrderElectronicInvoiceRequest;
import com.zbkj.common.response.OrderElectronicInvoiceResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.OrderElectronicInvoiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/admin/platform/orderElectronicInvoice")
@Api(tags = "订单发票")
public class  PlatformOrderElectronicInvoiceController {

    @Autowired
    private OrderElectronicInvoiceService orderElectronicInvoiceService;


    @ApiOperation(value = "修改发票信息")
    @RequestMapping(value = "/set", method = RequestMethod.POST)
    public CommonResult<OrderElectronicInvoiceRequest> set(@RequestBody OrderElectronicInvoiceRequest orderElectronicInvoiceRequest) {
        return CommonResult.success(orderElectronicInvoiceService.set(orderElectronicInvoiceRequest));
    }


    @ApiOperation(value = "获取发票列表")
    @RequestMapping(value = "/findByList", method = RequestMethod.POST)
    public CommonResult<PageInfo<OrderElectronicInvoiceResponse>> findByList
            (@RequestBody OrderElectronicInvoiceRequest orderElectronicInvoiceRequest) {
        return CommonResult.success(orderElectronicInvoiceService.findByList(orderElectronicInvoiceRequest));
    }


    @ApiOperation(value = "获取指定订单发票列表")
    @RequestMapping(value = "/getOrderNumberList", method = RequestMethod.POST)
    public CommonResult<PageInfo<OrderElectronicInvoiceResponse>> getOrderNumberList(@RequestBody OrderElectronicInvoiceRequest orderElectronicInvoiceRequest) {
        return CommonResult.success(orderElectronicInvoiceService.getOrderNumberList(orderElectronicInvoiceRequest));
    }

    @ApiOperation(value = "获取指定订单发票信息(单条)")
    @RequestMapping(value = "/getOrderNumber", method = RequestMethod.POST)
    public CommonResult<OrderElectronicInvoiceResponse> getOrderNumber(@RequestBody OrderElectronicInvoiceRequest orderElectronicInvoiceRequest) {
        return CommonResult.success(orderElectronicInvoiceService.getOrderNumber(orderElectronicInvoiceRequest));
    }

    @ApiOperation(value = "获取指定发票信息")
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public CommonResult<OrderElectronicInvoiceResponse> get(@PathVariable("id") Integer id) {
        return CommonResult.success(orderElectronicInvoiceService.get(id));
    }


}
